﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using EpsiRisk.MoteurJeu;

namespace EpsiRisk.AffichageJeu
{
    public class ClassZoneDeplacement : ClassZoneContextuelle
    {
        private Texture2D spritePlus;
        private Texture2D spriteMoins;
        private Texture2D spriteValider;
        private Texture2D spriteVide;

        private ClassBouton boutonPlus;
        private ClassBouton boutonMoins;
        private ClassBouton boutonValider;
        private ClassBouton boutonVide;

        internal override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);
            spriteBatch.Begin();
            spriteBatch.DrawString(ClassDonneesGlobales.SpriteTxt, "Pays Source : ", new Vector2(position.X + 300, position.Y + 6), Color.Red);
            if (ClassEtatPartie.sousTerritoireSelectionne != null)
            {
                string tmp = System.Text.Encoding.ASCII.GetString(System.Text.Encoding.GetEncoding(1251).GetBytes(ClassEtatPartie.sousTerritoireSelectionne.Nom));
                spriteBatch.DrawString(ClassDonneesGlobales.SpriteTxt, tmp, new Vector2(position.X + 340, position.Y + 24), Color.Red);
            }
            else
            {
                spriteBatch.DrawString(ClassDonneesGlobales.SpriteTxt, "Aucun", new Vector2(position.X + 340, position.Y + 24), Color.Red);
            }
            spriteBatch.DrawString(ClassDonneesGlobales.SpriteTxt, "Pays de destination : ", new Vector2(position.X + 300, position.Y + 42), Color.Red);
            if (ClassEtatPartie.sousTerritoireSelectionneBis != null)
            {
                string tmp = System.Text.Encoding.ASCII.GetString(System.Text.Encoding.GetEncoding(1251).GetBytes(ClassEtatPartie.sousTerritoireSelectionneBis.Nom));
                spriteBatch.DrawString(ClassDonneesGlobales.SpriteTxt, tmp, new Vector2(position.X + 340, position.Y + 60), Color.Red);
                string tmp_unite_libres = (ClassPhaseDeplacement.getUniteesADeplacer()).ToString();
                spriteBatch.DrawString(ClassDonneesGlobales.SpriteTxt, tmp_unite_libres, new Vector2(position.X + 58, position.Y + 56), Color.Red);
            }
            else
            {
                spriteBatch.DrawString(ClassDonneesGlobales.SpriteTxt, "Aucun", new Vector2(position.X + 340, position.Y + 60), Color.Red);
            }

            spriteBatch.End();
        }

        internal override void initialiser(Microsoft.Xna.Framework.Content.ContentManager content)
        {
            spritePlus = content.Load<Texture2D>("Sprites/PopupMenu/NouveauJeu/SpritePlus");
            spriteMoins = content.Load<Texture2D>("Sprites/PopupMenu/NouveauJeu/SpriteMoins");
            spriteValider = content.Load<Texture2D>("Sprites/PopupMenu/NouveauJeu/SpriteValider");
            spriteVide = content.Load<Texture2D>("Sprites/PopupMenu/NouveauJeu/SpriteVide");
            boutonPlus = new ClassBouton(spritePlus);
            boutonPlus.position = new Vector2(88, 55);
            boutonPlus.height = 28;
            boutonPlus.width = 29;
            boutonPlus.Clicked += new EventHandler(boutonPlus_Clicked);
            AddBouton(boutonPlus);
            boutonMoins = new ClassBouton(spriteMoins);
            boutonMoins.position = new Vector2(13, 55);
            boutonMoins.height = 28;
            boutonMoins.width = 29;
            boutonMoins.Clicked += new EventHandler(boutonMoins_Clicked);
            AddBouton(boutonMoins);
            boutonValider = new ClassBouton(spriteValider);
            boutonValider.position = new Vector2(123, 55);
            boutonValider.height = 28;
            boutonValider.width = 80;
            boutonValider.Clicked += new EventHandler(boutonValider_Clicked);
            AddBouton(boutonValider);
            boutonVide = new ClassBouton(spriteVide);
            boutonVide.position = new Vector2(45, 55);
            boutonVide.height = 28;
            boutonVide.width = 40;
            AddBouton(boutonVide);
        }

        void boutonMoins_Clicked(object sender, EventArgs e)
        {
            ClassPhaseDeplacement.diminuer();
        }

        void boutonPlus_Clicked(object sender, EventArgs e)
        {
            ClassPhaseDeplacement.augmenter();
        }

        void boutonValider_Clicked(object sender, EventArgs e)
        {
            ClassPhaseDeplacement.deplacer();
        }

        internal override void clicXY(int x, int y)
        {
            base.clicXY(x, y);
        }
    }
}

